﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<div class="commonbox">
    <div class="footerbox">
        <table style="width: 100%;">
            <tr style="text-align: center">
                <td style="width: 22px; height: 22px;">
                    <% if (Url.RequestContext.RouteData.Values["controller"].ToString().ToLower() != "home")
                       {

                       }
                       String nick = Wild2.Models.Auth.AuthOnSite.GetUserNick();
                       Int32? UserID = Wild2.Models.Auth.AuthOnSite.GetUserId();
                    %>
                    <% if (UserID.HasValue)
                       {
                           String homeurl = Wild2.Models.User.Settings.GetUserHomeUrl(UserID.Value);
                           if (!String.IsNullOrEmpty(homeurl))
                           {
                            %>
                            <a href="<%= Url.Action(homeurl.Split(new char[] { ':' })[1], homeurl.Split(new char[] { ':' })[0], new { controller = homeurl.Split(new char[] { ':' })[0], action = homeurl.Split(new char[] { ':' })[1], parameter = 0 }) %>">
                            <img alt="[ - ]" src="/Content/imgs/home.png" style="border: 0px;" /></a>
                            <%                            
                           }
                           else
                           {
                               String lastTab = Wild2.Models.ViewTabs.ViewTabs.getCurrentTab();
                               if (lastTab != "")
                               {
                                   string controller = lastTab.ToString().Split(new char[] { '|' })[0];
                                   string view = lastTab.ToString().Split(new char[] { '|' })[1];
                                   if ((Url.RequestContext.RouteData.Values["controller"].ToString() == controller) && (Url.RequestContext.RouteData.Values["action"].ToString() == view))
                                   {
                                       controller = "Home";
                                       view = "Index";
                                   }
                            %>
                            <a href="<%= Url.Action(view, controller, new { parameter = 0 }) %>">
                            <img alt="[ - ]" src="/Content/imgs/home.png" style="border: 0px;" /></a>
                            <%     
                               }
                               else
                               {
                            %>
                            <a href="<%= Url.Action("Index", "Home", new { controller = "Home", action = "Index", parameter = 0 }) %>">
                            <img alt="[ - ]" src="/Content/imgs/home.png" style="border: 0px;" /></a>
                            <% 
                               }
                           }
                           %>
                    <% }
                       else
                       { %>
                    <a href="<%= Url.Action("Index", "Home", new { controller = "Home", action = "Index", parameter = 0 }) %>">
                        <img alt="[ - ]" src="/Content/imgs/home.png" style="border: 0px;" /></a>
                    <% } %>
                </td>
                <td style="width: 22px; height: 22px;">
                    <a title="Справка" href="<%= Url.Action("Index", "Help") %>">
                        <img alt="Справка" src="/Content/imgs/help.png" style="border: 0px;" /></a>
                </td>
                <td style="width: 22px; height: 22px;">
                    <a title="Поиск" href="<%= Url.Action("Index", "Search") %>">
                        <img alt="Поиск" src="/Content/imgs/find.png" style="border: 0px;" /></a>
                </td>
                <% //if ((ViewData["showlegend"] != null) && (Convert.ToBoolean(ViewData["showlegend"]) == true))
                    if (Url.RequestContext.RouteData.Values["controller"].ToString().ToLower() == "home")
                    { %>
                <%--<td style="width: 22px; height: 22px;">
                    <a title="Блог" href="<%= Url.Action("Index", "Blog") %>"><img alt="Вход" src="/Content/imgs/blog.png" style="border: 0px;" /></a>
                </td>--%>
                <% } %>
                <td>
                    <% if (!String.IsNullOrEmpty(nick))
                       {
                           if (UserID.HasValue)
                           {%>
                            <a href="<%= Url.Action("Index", "Office", new { controller = "Office", action = "Index" }) %>">
                                <span>
                                    <%= HttpUtility.HtmlEncode(Wild2.Models.Text.Helper.Cutstring(nick, 10, 10))%></span>
                            </a>
                            <% 
                           }
                           else
                           {
                             %>
                                <span>
                                    <%= HttpUtility.HtmlEncode(Wild2.Models.Text.Helper.Cutstring(nick, 10, 10))%></span>
                            <%  
                           }
                       }
                       else
                       { %>
                    <a href="<%= Url.Action("Index", "Login", new { controller = "Login", action = "Index" }) %>">
                        <span>
                            <%= Resources.Common.Login %></span></a>
                    <% } %>
                </td>
                <% //if ((ViewData["showlegend"] != null) && (Convert.ToBoolean(ViewData["showlegend"]) == true))
                    if (Url.RequestContext.RouteData.Values["controller"].ToString().ToLower() == "home")
                    { %>
                <td style="width: 22px; height: 22px;">
                    <a title="Избранное" href="<%= Url.Action("Index", "Favorites") %>">
                        <img alt="Избранное" src="/Content/imgs/bookmarks.png" style="border: 0px;" /></a>
                </td>
                <% } else { %>
                <td style="width: 22px; height: 22px;">
                    <a title="Избранное" href="<%= Url.Action("Index", "Favorites") %>">
                        <img alt="Избранное" src="/Content/imgs/bookmarks.png" style="border: 0px;" /></a>
                </td>
                <% } %>
                <td style="width: 22px; height: 22px;">
                    <a title="Пользователи" href="<%= Url.Action("Top", "User") %>">
                        <img alt="Пользователи" src="/Content/imgs/users.png" style="border: 0px;" /></a>
                </td>
                <td style="width: 22px; height: 22px;">
                    <% if (Wild2.Models.Auth.AuthOnSite.GetUserId().HasValue)
                       {%>
                    <a title="Выход" href="<%= Url.Action("Logout", "Login") %>">
                        <img alt="Выход" src="/Content/imgs/logout.png" style="border: 0px;" /></a>
                    <% }
                       else
                       { %>
                    <a title="Вход" href="<%= Url.Action("Index", "Login", new { controller = "Login", action = "Index" }) %>">
                        <img alt="Вход" src="/Content/imgs/login.png" style="border: 0px;" /></a>
                    <% } %>
                </td>
            </tr>
        </table>
    </div>
</div>
